<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class AppendanceLog extends BaseModel
{
    use HasFactory;
    protected $table = 'appendance_log';
    // 允许批量操作的字段
    protected $fillable = ['user_id','date','appendance_time','created_at','updated_at'];

    public function scopeSearch($query,$params)
    {
        //p($params);
        if(!empty($params['users_id'])){
            $query->where('user_id',$params['users_id']);
        }
        if(!empty($params['date'])){
            $query->where('date',$params['date']);
        }
        return $query;
    }

    public function employee(){
        return $this->hasOne(Employee::class,'user_id','user_id');
    }
}
